package cn.wgx.security.mapper;

import cn.wgx.security.entity.Permission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PermissionMapper extends BaseMapper<Permission> {

    @Select("SELECT " +
            "p.* " +
            "FROM " +
            "tb_user_role ur " +
            "LEFT JOIN tb_role_permission rp ON ur.role_id = rp.role_id " +
            "LEFT JOIN tb_permission p ON rp.permission_id = p.id " +
            "WHERE " +
            "ur.user_id = #{userId}")
    List<Permission> getPerByUserId(Long userId);

}
